package GameBoard;

import java.util.Random;
import java.util.Vector;

import GameElements.Pawn;
import GameElements.Tile;
import Player.Player;

public abstract class GameBoard
{
	protected static int height = 10;
	protected static int width = 12;	
	protected Tile[][] table = new Tile[width][height];
	protected Vector<Tile> stock = new Vector<Tile>();
	
	public abstract void distributePawn(Vector<Player> player);
	public abstract boolean canAdd(Tile t, int i, int j);	
	public abstract void add(Tile t, int i, int j);	
	public abstract boolean canAdd(Pawn pawn, int i, int j, int indexPawnInTile);	
	public abstract void add(Pawn pawn, int i, int j, int indexPawnInTile);
	
	protected void melangerStock()
	{
		Vector<Tile> tile = new Vector<Tile>();
		for(int i=0; i< stock.size(); i++)
			tile.add(stock.get(i));
		stock.clear();
		
		Random r = new Random();
		//add to stock randomly
		while (tile.size() != 0)
		{
			int index = r.nextInt(tile.size());
			stock.add(tile.get(index));
			tile.remove(index);
		}
	}
	
	public Tile piocher()
	{
		Tile t = null;
		if(stock.size() != 0)
		{	
			t = stock.get(stock.size()-1);
			stock.remove(stock.size()-1);
		}
		return t;
	}

	
	//getters
	public Tile[][] getTable() 
	{
		return table;
	}		
	public Vector<Tile> getStock() 
	{
		return stock;
	}	
}
